*** social background
recode education (10 = 9) (11 = 9)
gen schooling=education-1

gen female=GEND
recode female (2 = 1) (1 = 0)
lab def female 0 "male" 1 "female"

gen age=ELYEAR-YOB

*** national economic evaluations DK coded as about the same
gen nationaleconomy=Q16 
recode nationaleconomy (1 = 0) (2 = 1) (3 = 2) (9 = 1)
lab def nationaleconomy 0 "worse" 1 "about the same" 2 "better"

*** Correcting coding for Bavaria EU
replace nationaleconomy=0 if Q16==3 & ELECID==19
replace nationaleconomy=2 if Q16==1 & ELECID==19

gen worsenational=nationaleconomy
replace worsenational=1 if nationaleconomy==0
replace worsenational=0 if nationaleconomy>0
lab def worsenational 0 "not worse" 1 "worse"

gen betternational=nationaleconomy
replace betternational=0 if nationaleconomy==1
replace betternational=1 if nationaleconomy==2
lab def betternational 0 "not better" 1 "better"

*** subnational economic evaluations DKs coded as about the same
gen regionaleconomy=Q15
recode regionaleconomy (1 = 0) (2 = 1) (3 = 2) (9 = 1)
lab def regionaleconomy 0 "worse" 1 "about the same" 2 "better"

gen worseregional=regionaleconomy
replace worseregional=1 if regionaleconomy==0
replace worseregional=0 if regionaleconomy>0
lab def worseregional 0 "not worse" 1 "worse"

gen betterregional=regionaleconomy
replace betterregional=0 if regionaleconomy==1
replace betterregional=1 if regionaleconomy==2
lab def betterregional 0 "not better" 1 "better"

*** national attributions of responsibility
gen nationalresponsibility=Q16A
recode nationalresponsibility (1 = 0) (2 = 1) (3 = 2) (9 =1 ) 
lab def nationalresponsibility 0 "worse" 1 "not much difference" 2 "better"

**** dichotomizes nationalresponsibility 
gen NATresp=nationalresponsibility
replace NATresp=1 if nationalresponsibility==0
replace NATresp=0 if nationalresponsibility>0
lab def NATresp 0 "not worse" 1 "worse"

***limits NATresp to those who thought economy had got worse

gen NATworse=NATresp if worsenational==1

**** national responsibility for improved economy

gen NATbetter=0 if betternational==1
replace NATbetter=. if betternational==0 
replace NATbetter=1 if nationalresponsibility==2 & betternational==1

*** creates 3 category variable for attributing responsibility

replace NATresp=2 if NATresp==1 & worsenational==1
replace NATresp=1 if NATresp==0 & worsenational==1
replace NATresp=0 if NATresp==0 & worsenational==0
replace NATresp=0 if NATresp==1 & worsenational==0

*** subnational attributions of responsibility
gen regionalresponsibility=Q15A
recode regionalresponsibility (1 = 0) (2 =1 ) (3 = 2) (9 = 1) 
lab def regionalresponsibility 0 "worse" 1 "not much difference" 2 "better"

**** dichotomizes regionalresponsibility 
gen REGresp=regionalresponsibility
replace REGresp=1 if regionalresponsibility==0
replace REGresp=0 if regionalresponsibility>0
lab def REGresp 0 "not worse" 1 "worse"

***limits REGresp to those who thought economy had got worse

gen REGworse=REGresp if worseregional==1

*** regional responsibility for improved economy

gen REGbetter=0 if betterregional==1
replace REGbetter=. if betterregional==0
replace REGbetter=1 if regionalresponsibility==2 & betterregional==1

*** Creates 3 category variable for attributing responsibility

replace REGresp=2 if REGresp==1 & worseregional==1
replace REGresp=1 if REGresp==0 & worseregional==1
replace REGresp=0 if REGresp==0 & worseregional==0
replace REGresp=0 if REGresp==1 & worseregional==0

*** attachments
gen regionalattach=Q43C
replace regionalattach=. if Q43C==99

gen nationalattach=Q43B
replace nationalattach=. if Q43B==99

gen attachdiff=nationalattach-regionalattach
gen regionmore=1 if attachdiff<0
replace regionmore=0 if attachdiff>-1
replace regionmore=. if nationalattach==.
replace regionmore=. if regionalattach==.
lab var regionmore "more attached to region"

gen nationalmore=1 if attachdiff>0
replace nationalmore=0 if attachdiff<1
replace nationalmore=. if nationalattach==.
replace nationalmore=. if regionalattach==.
lab var nationalmore "more attached to nation"

*** corruption DK coded as hardly any
gen nationalcorrupt=Q50B
recode nationalcorrupt (1 = 0) (2 = 1) (3 = 2) (4 = 3) (9 = 0) 

gen regionalcorrupt=Q50A
recode regionalcorrupt (1 = 0) (2 = 1) (3 = 2) (4 = 3) (9 = 0) 

gen municipalcorrupt=Q50C
recode municipalcorrupt (1 = 0) (2 = 1) (3 = 2) (4 = 3) (9 = 0) 

lab def nationalcorrupt 0 "hardly any" 1 "a little" 2 "some" 3 "a lot"
lab def regionalcorrupt 0 "hardly any" 1 "a little" 2 "some" 3 "a lot"
lab def municipalcorrupt 0 "hardly any" 1 "a little" 2 "some" 3 "a lot"

*** eliminate missing values for incumbent vote
replace INCUMBENT=. if INCUMBENT==99

*** party identification
gen partyID=0
replace partyID=1 if ELECID==5 & Q47A==2
replace partyID=1 if ELECID==5 & Q47A==9
replace partyID=1 if ELECID==6 & Q47A==2. 
replace partyID=1 if ELECID==6 & Q47A==9
replace partyID=1 if ELECID==7 & Q47A==1.
replace partyID=1 if ELECID==8 & Q47A==4. 
replace partyID=1 if ELECID==9 & Q47A==1
replace partyID=1 if ELECID==10 & Q47A==1
replace partyID=1 if ELECID==10 & Q47A==4.
replace partyID=1 if ELECID==11 & Q47A==1
replace partyID=1 if ELECID==11 & Q47A==4. 
replace partyID=1 if ELECID==12 & Q47A==1
replace partyID=1 if ELECID==12 & Q47A==5.
replace partyID=1 if ELECID==13 & Q47A==1
replace partyID=1 if ELECID==13 & Q47A==5. 
replace partyID=1 if ELECID==16 & Q47A==1.
replace partyID=1 if ELECID==17 & Q47A==1.
replace partyID=1 if ELECID==18 & Q47A==1
replace partyID=1 if ELECID==18 & Q47A==2
replace partyID=1 if ELECID==19 & Q47A==1
replace partyID=1 if ELECID==19 & Q47A==2
replace partyID=1 if ELECID==20 & Q47A==2.
replace partyID=1 if ELECID==21 & Q47A==2.
replace partyID=1 if ELECID==22 & Q47A==1.
replace partyID=1 if ELECID==22 & Q47A==4.
replace partyID=1 if ELECID==22 & Q47A==6.
replace partyID=1 if ELECID==23 & Q47A==2.
replace partyID=1 if ELECID==24 & Q47A==2.

gen opposeID=0.
replace opposeID=1 if partyID==0 & Q47==1

*** political knowledge
gen knowledge=Q10
gen highinformation=0
replace highinformation=1 if knowledge==1 & ELECID==5
replace highinformation=1 if knowledge==1 & ELECID==6
replace highinformation=1 if knowledge>.75 & ELECID==7
replace highinformation=1 if knowledge==1 & ELECID==9
replace highinformation=1 if knowledge==1 & ELECID==10
replace highinformation=1 if knowledge==1 & ELECID==12
replace highinformation=1 if knowledge==1 & ELECID==8
replace highinformation=1 if knowledge>.5 & ELECID==24
replace highinformation=1 if knowledge>.30 & ELECID==11
replace highinformation=1 if knowledge>.50 & ELECID==13
replace highinformation=1 if knowledge==1 & ELECID==22
replace highinformation=1 if knowledge==1 & ELECID==23
replace highinformation=1 if knowledge>.30 & ELECID==16
replace highinformation=1 if knowledge>.15 & ELECID==17
replace highinformation=1 if knowledge>.35 & ELECID==20
replace highinformation=1 if knowledge>.40 & ELECID==21
replace highinformation=1 if knowledge>.30 & ELECID==18
replace highinformation=1 if knowledge>.30 & ELECID==19



********************************************************

**** EXPLAINING EVALUATIONS Table 1

**** National Economic Evaluationsat time of national survey

*** IDF national
logit worsenational i.female age schooling  i.partyID i.opposeID  if ELECID==5 
margins, dydx(partyID)
margins, dydx(opposeID)

*** Provence national
logit worsenational  i.female age schooling i.partyID i.opposeID  if ELECID==6 
margins, dydx(partyID)
margins, dydx(opposeID)

*** Catalonia national
logit worsenational  i.female age schooling  i.partyID i.opposeID  if ELECID==7
margins, dydx(partyID)
margins, dydx(opposeID)

*** Madrid national
logit worsenational  i.female age schooling i.partyID i.opposeID if ELECID==9 
margins, dydx(partyID)
margins, dydx(opposeID)

*** Lower Saxony
logit worsenational  i.female age schooling i.partyID i.opposeID if ELECID==10 
margins, dydx(partyID)
margins, dydx(opposeID)
 
logit betternational  i.female age schooling i.partyID i.opposeID   if ELECID==10 
margins, dydx(partyID)
margins, dydx(opposeID)

*** Bavaria national
logit worsenational  i.female age schooling i.partyID i.opposeID if ELECID==12
margins, dydx(partyID)
margins, dydx(opposeID)

logit betternational  i.female age schooling i.partyID i.opposeID   if ELECID==12
margins, dydx(partyID)
margins, dydx(opposeID)

***Subnational Economic Evaluations at time of subnational survey

*** Paris subnational
logit worseregional  i.female age schooling i.partyID i.opposeID if ELECID==22
margins, dydx(partyID)
margins, dydx(opposeID)

*** Marseille subnational
logit worseregional  i.female age schooling i.partyID i.opposeID if ELECID==23
margins, dydx(partyID)
margins, dydx(opposeID)

*** Catalonia subnational
logit worseregional  i.female age schooling i.partyID i.opposeID if ELECID==8
margins, dydx(partyID)
margins, dydx(opposeID)

*** Madrid subnational no data

*** Lower Saxony subnational
logit worseregional  i.female age schooling i.partyID i.opposeID if ELECID==11
margins, dydx(partyID)
margins, dydx(opposeID)
 
logit  betterregional  i.female age schooling i.partyID i.opposeID if ELECID==11
margins, dydx(partyID)
margins, dydx(opposeID)

*** Bavaria subnational
logit worseregional  i.female age schooling i.partyID i.opposeID if ELECID==13
margins, dydx(partyID)
margins, dydx(opposeID)

logit betterregional  i.female age schooling i.partyID i.opposeID if ELECID==13
margins, dydx(partyID)
margins, dydx(opposeID)

**************************************************************

**** EXPLAINING ATTRIBUTIONS OF RESPONSIBILITY Table 2

**** National Attributions

*** IDF national
logit NATworse i.partyID i.opposeID i.nationalmore i.highinformation if ELECID==5 & NATworse<2
margins, dydx(partyID)
margins, dydx(opposeID)
margins, dydx(highinformation)
margins, dydx(nationalmore)

*** Provence national
logit NATworse i.partyID i.opposeID i.nationalmore i.highinformation if ELECID==6 & NATworse<2 
margins, dydx(partyID)
margins, dydx(opposeID)
margins, dydx(highinformation)
margins, dydx(nationalmore)

*** Catalonia national
logit NATworse i.partyID i.opposeID i.nationalmore i.highinformation if ELECID==7 & NATworse<2 
margins, dydx(partyID)
margins, dydx(opposeID)
margins, dydx(highinformation)
margins, dydx(nationalmore)

*** Madrid national
logit NATworse i.partyID i.opposeID i.nationalmore i.highinformation if ELECID==9 & NATworse<2 
margins, dydx(partyID)
margins, dydx(opposeID)
margins, dydx(highinformation)
margins, dydx(nationalmore)

*** Lower Saxony
logit NATworse i.partyID i.opposeID i.nationalmore i.highinformation if ELECID==10 & NATworse<2 
margins, dydx(partyID)
margins, dydx(opposeID)
margins, dydx(highinformation)
margins, dydx(nationalmore)

*** Bavaria national
logit NATworse i.partyID i.opposeID i.nationalmore  i.highinformation if ELECID==12 & NATworse<2 
margins, dydx(partyID)
margins, dydx(opposeID)
margins, dydx(highinformation)
margins, dydx(nationalmore)

*** Lower Saxony
logit NATbetter i.partyID i.opposeID i.nationalmore i.highinformation if ELECID==10 & NATbetter<2 
margins, dydx(partyID)
margins, dydx(opposeID)
margins, dydx(highinformation)
margins, dydx(nationalmore)

*** Bavaria national
logit NATbetter i.partyID i.opposeID i.nationalmore  i.highinformation if ELECID==12 & NATbetter<2 
margins, dydx(partyID)
margins, dydx(opposeID)
margins, dydx(highinformation)
margins, dydx(nationalmore)

***** Subnational Attributions

*** Catalonia subnational
logit REGworse partyID opposeID i.regionmore i.highinformation if ELECID==8 & REGworse<2
margins, dydx(partyID)
margins, dydx(opposeID)
margins, dydx(highinformation)
margins, dydx(regionmore)

*** Madrid subnational Missing

*** Lower Saxony subnational
logit REGworse i.partyID i.opposeID i.regionmore i.highinformation if ELECID==11 & REGworse<2 
margins, dydx(partyID)
margins, dydx(opposeID)
margins, dydx(highinformation)
margins, dydx(regionmore)

*** Bavaria subnational
logit REGworse i.partyID i.opposeID i.regionmore i.highinformation if ELECID==13 & REGworse<2
margins, dydx(partyID)
margins, dydx(opposeID)
margins, dydx(highinformation)
margins, dydx(regionmore)

*** Lower Saxony subnational
logit REGbetter i.partyID i.opposeID i.regionmore i.highinformation if ELECID==11 & REGbetter<2 
margins, dydx(partyID)
margins, dydx(opposeID)
margins, dydx(highinformation)
margins, dydx(regionmore)

*** Bavaria subnational
logit REGbetter i.partyID i.opposeID i.regionmore  i.highinformation if ELECID==13 & REGbetter<2 
margins, dydx(partyID)
margins, dydx(opposeID)
margins, dydx(highinformation)
margins, dydx(regionmore)

*** Paris municipal MISSING

*** Marseille municipal MISSING

***********************************************************************

**** VOTE MODELS FOR ECONOMIC EVALUATIONS Table 3

*** NATIONAL VOTE

*** IDF national
logit INCUMBENT i.worsenational i.partyID i.opposeID if ELECID==5  & betternational==0
margins, dydx(worsenational)
margins, dydx(partyID)
margins, dydx(opposeID)

*** Provence national
logit INCUMBENT i.worsenational i.partyID i.opposeID if ELECID==6  & betternational==0
margins, dydx(worsenational)
margins, dydx(partyID)
margins, dydx(opposeID)

*** Catalonia national
logit INCUMBENT i.worsenational i.partyID i.opposeID if ELECID==7  & betternational==0
margins, dydx(worsenational)
margins, dydx(partyID)
margins, dydx(opposeID)

*** Madrid national
logit INCUMBENT i.worsenational i.partyID i.opposeID if ELECID==9  & betternational==0
margins, dydx(worsenational)
margins, dydx(partyID)
margins, dydx(opposeID)

*** Lower Saxony
logit INCUMBENT i.worsenational i.partyID i.opposeID if ELECID==10  & betternational==0
margins, dydx(worsenational)
margins, dydx(partyID)
margins, dydx(opposeID)

*** Bavaria national
logit INCUMBENT i.worsenational i.partyID i.opposeID if ELECID==12  & betternational==0
margins, dydx(worsenational)
margins, dydx(partyID)
margins, dydx(opposeID)

*** SUBNATIONAL VOTE

*** Marseille
logit INCUMBENT i.worseregional i.partyID i.opposeID if ELECID==23 & betterregional==0
margins, dydx(worseregional)
margins, dydx(partyID)
margins, dydx(opposeID)

*** Paris
logit INCUMBENT i.worseregional i.partyID i.opposeID if ELECID==22  & betterregional==0
margins, dydx(worseregional)
margins, dydx(partyID)
margins, dydx(opposeID)

*** Catalonia subnational
logit INCUMBENT i.worseregional i.partyID i.opposeID if ELECID==8 & betterregional==0
margins, dydx(worseregional)
margins, dydx(partyID)
margins, dydx(opposeID)

*** Madrid subnational Missing

*** Lower Saxony regional
logit INCUMBENT i.worseregional i.partyID i.opposeID if ELECID==11  & betterregional==0
margins, dydx(worseregional)
margins, dydx(partyID)
margins, dydx(opposeID)

*** Bavaria subnational
logit INCUMBENT i.worseregional i.partyID i.opposeID if ELECID==13  & betterregional==0
margins, dydx(worseregional)
margins, dydx(partyID)
margins, dydx(opposeID)

*** TAKING ACCOUNT OF RESPONSIBILITY ATTRIBUTIONS

**** National Vote

*** IDF national
logit INCUMBENT i.NATresp i.partyID i.opposeID if ELECID==5 & betternational==0
margins, dydx(NATresp)
margins, dydx(partyID)
margins, dydx(opposeID)

*** Provence national
logit INCUMBENT i.NATresp i.partyID i.opposeID if ELECID==6  & betternational==0
margins, dydx(NATresp)
margins, dydx(partyID)
margins, dydx(opposeID)

*** Catalonia national
logit INCUMBENT i.NATresp i.partyID i.opposeID if ELECID==7  & betternational==0
margins, dydx(NATresp)
margins, dydx(partyID)
margins, dydx(opposeID)

*** Madrid national
logit INCUMBENT i.NATresp i.partyID i.opposeID if ELECID==9  & betternational==0
margins, dydx(NATresp)
margins, dydx(partyID)
margins, dydx(opposeID)

*** Lower Saxony
logit INCUMBENT i.NATresp i.partyID i.opposeID if ELECID==10  & betternational==0
margins, dydx(NATresp)
margins, dydx(partyID)
margins, dydx(opposeID)

*** Bavaria national
logit INCUMBENT i.NATresp i.partyID i.opposeID if ELECID==12  & betternational==0
margins, dydx(NATresp)
margins, dydx(partyID)
margins, dydx(opposeID)


**** Subnational Vote

*** Marseille Missng 

*** Paris Missing

*** Catalonia subnational
logit INCUMBENT i.REGresp i.partyID i.opposeID if ELECID==8  & betterregional==0
margins, dydx(REGresp)
margins, dydx(partyID)
margins, dydx(opposeID)

*** Madrid subnational Missing

*** Lower Saxony subnational
logit INCUMBENT i.REGresp i.partyID i.opposeID if ELECID==11  & betterregional==0
margins, dydx(REGresp)
margins, dydx(partyID)
margins, dydx(opposeID)

*** Bavaria subnational
logit INCUMBENT i.REGresp i.partyID i.opposeID if ELECID==13 & worseregional<2  & betterregional==0
margins, dydx(REGresp)
margins, dydx(partyID)
margins, dydx(opposeID)

**** Adding Interactions with Knowledge--impact of negative evaluation does not vary by knowledge

**** National Vote

*** IDF national
logit INCUMBENT i.worsenational##i.highinformation i.partyID i.opposeID if ELECID==5 & betternational==0
margins, dydx(partyID)
margins, dydx(opposeID)
margins worsenational##highinformation
margins, dydx(highinformation) at(worsenational=(0 1))

*** Provence national
logit INCUMBENT ii.worsenational##i.highinformation  i.partyID i.opposeID if ELECID==6  & betternational==0
margins, dydx(partyID)
margins, dydx(opposeID)
margins worsenational##highinformation
margins, dydx(highinformation) at(worsenational=(0 1))

*** Catalonia national
logit INCUMBENT i.worsenational##i.highinformation  i.partyID i.opposeID if ELECID==7  & betternational==0
margins, dydx(partyID)
margins, dydx(opposeID)
margins worsenational##highinformation
margins, dydx(highinformation) at(worsenational=(0 1))

*** Madrid national
logit INCUMBENT i.worsenational##i.highinformation  i.partyID i.opposeID if ELECID==9  & betternational==0
margins, dydx(partyID)
margins, dydx(opposeID)
margins worsenational##highinformation
margins, dydx(highinformation) at(worsenational=(0 1))

*** Lower Saxony
logit INCUMBENT i.worsenational##i.highinformation  i.partyID i.opposeID if ELECID==10  & betternational==0
margins, dydx(partyID)
margins, dydx(opposeID)
margins worsenational##highinformation
margins, dydx(highinformation) at(worsenational=(0 1))

*** Bavaria national
logit INCUMBENT i.worsenational##i.highinformation  i.partyID i.opposeID if ELECID==12  & betternational==0
margins, dydx(partyID)
margins, dydx(opposeID)
margins worsenational##highinformation
margins, dydx(highinformation) at(worsenational=(0 1))


**** Subnational Vote

*** Marseille Missng 

*** Paris Missing

*** Catalonia subnational
logit INCUMBENT worseregional##highinformation i.partyID i.opposeID if ELECID==8  & betterregional==0
margins, dydx(partyID)
margins, dydx(opposeID)
margins worseregional##highinformation
margins, dydx(highinformation) at(worseregional=(0 1))

*** Madrid subnational Missing

*** Lower Saxony subnational
logit INCUMBENT worseregional##highinformation i.partyID i.opposeID if ELECID==11  & betterregional==0
margins, dydx(partyID)
margins, dydx(opposeID)
margins worseregional##highinformation
margins, dydx(highinformation) at(worseregional=(0 1))

*** Bavaria subnational
logit INCUMBENT worseregional##highinformation i.partyID i.opposeID if ELECID==13 & worseregional<2  & betterregional==0
margins, dydx(partyID)
margins, dydx(opposeID)
margins worseregional##highinformation
margins, dydx(highinformation) at(worseregional=(0 1))

**********************************************************************


*** Corruption

*** Perceived National Corruption Table 4

*** IDF national
regress nationalcorrupt i.partyID i.opposeID i.nationalmore i.highinformation i.female age schooling if ELECID==5 

*** Provence national
regress nationalcorrupt i.partyID i.opposeID i.nationalmore   i.highinformation i.female age schooling if ELECID==6 

*** Catalonia national
regress nationalcorrupt i.partyID i.opposeID i.nationalmore  i.highinformation i.female age schooling if ELECID==7

*** Madrid national
regress nationalcorrupt i.partyID i.opposeID i.nationalmore  i.highinformation i.female age schooling if ELECID==9 

*** Lower Saxony
regress nationalcorrupt i.partyID i.opposeID i.nationalmore  i.highinformation i.female age schooling if ELECID==10 

*** Bavaria national
regress nationalcorrupt i.partyID i.opposeID i.nationalmore   i.highinformation i.female age if ELECID==12

***Perceived Subnational Corruption 

*** Paris
regress municipalcorrupt i.partyID i.opposeID i.highinformation i.female age schooling if ELECID==22

*** Marseille
regress municipalcorrupt i.partyID i.opposeID i.highinformation i.female age schooling if ELECID==23

*** Catalonia subnational
regress regionalcorrupt i.partyID i.opposeID i.regionmore  i.highinformation i.female age schooling if ELECID==8

*** Madrid subnational
regress regionalcorrupt i.partyID i.opposeID i.regionmore  i.highinformation i.female age schooling if ELECID==24

*** Lower Saxony subnational
regress regionalcorrupt i.partyID i.opposeID i.regionmore  i.highinformation i.female age schooling if ELECID==11

*** Bavaria subnational
regress regionalcorrupt i.partyID i.opposeID i.regionmore   i.highinformation i.female age schooling if ELECID==13


**** Impact of Corruption on Incumbent Vote

**** National Vote Figure 4

*** IDF national
logit INCUMBENT nationalcorrupt i.partyID i.opposeID if ELECID==5  
margins, at(nationalcorrupt=(0 (1) 3))
marginsplot, recast(line) recastci(rarea) saving(IDF, replace)

*** Provence national
logit INCUMBENT nationalcorrupt  i.partyID i.opposeID if ELECID==6 
margins, at(nationalcorrupt=(0 (1) 3))
marginsplot, recast(line) recastci(rarea) saving(provence)

*** Catalonia national
logit INCUMBENT nationalcorrupt  i.partyID i.opposeID if ELECID==7 
margins, at(nationalcorrupt=(0 (1) 3))
marginsplot, recast(line) recastci(rarea) saving(cataloniaN)

*** Madrid national
logit INCUMBENT nationalcorrupt  i.partyID i.opposeID if ELECID==9 
margins, at(nationalcorrupt=(0 (1) 3))
marginsplot, recast(line) recastci(rarea) saving(madridN)

*** Lower Saxony
logit INCUMBENT nationalcorrupt   i.partyID i.opposeID if ELECID==10
margins, at(nationalcorrupt=(0 (1) 3))
marginsplot, recast(line) recastci(rarea) saving(saxonyN)

*** Bavaria national
logit INCUMBENT nationalcorrupt i.partyID i.opposeID if ELECID==12
margins, at(nationalcorrupt=(0 (1) 3))
marginsplot, recast(line) recastci(rarea) saving(bavariaN)

gr combine IDF.gph provence.gph cataloniaN.gph madridN.gph bavariaN.gph saxonyN.gph , col(2) ysize(2) xsize(2)


**** Subnational Vote Figure 5

*** Paris 
logit INCUMBENT municipalcorrupt  i.partyID i.opposeID if ELECID==22
margins, at(municipalcorrupt=(0 (1) 3))
marginsplot, recast(line) recastci(rarea) saving(paris)

*** Marseille
logit INCUMBENT municipalcorrupt i.partyID i.opposeID if ELECID==23  
margins, at(municipalcorrupt=(0 (1) 3))
marginsplot, recast(line) recastci(rarea) saving(marseille, replace)

*** Catalonia subnational
logit INCUMBENT regionalcorrupt  i.partyID i.opposeID if ELECID==8 
margins, at(regionalcorrupt=(0 (1) 3))
marginsplot, recast(line) recastci(rarea) saving(cataloniaS)

*** Madrid subnational
logit INCUMBENT regionalcorrupt  i.partyID i.opposeID if ELECID==24 
margins, at(regionalcorrupt=(0 (1) 3))
marginsplot, recast(line) recastci(rarea) saving(madridS)

*** Bavaria subnational
logit INCUMBENT regionalcorrupt  i.partyID i.opposeID if ELECID==13
margins, at(regionalcorrupt=(0 (1) 3))
marginsplot, recast(line) recastci(rarea) saving(madridS)

**** Lower Saxony subnational
logit INCUMBENT regionalcorrupt   i.partyID i.opposeID if ELECID==11
margins, at(regionalcorrupt=(0 (1) 3))
marginsplot, recast(line) recastci(rarea) saving(saxonyS)

gr combine paris.gph marseille.gph cataloniaS.gph madridS.gph bavariaS.gph saxonyS.gph , col(2) ysize(2) xsize(2)


*********************************************************

**** Examining Impact of Cross-level Economic Evaluations Table 5

**** National Vote

*** IDF national
logit INCUMBENT i.worsenational i.worseregional i.partyID i.opposeID if ELECID==5  & betternational==0
margins, dydx(worsenational)
margins, dydx(worseregional)

*** Provence national
logit INCUMBENT i.worsenational i.worseregional i.partyID i.opposeID if ELECID==6  & betternational==0
margins, dydx(worsenational)
margins, dydx(worseregional)

*** Catalonia national
logit INCUMBENT i.worsenational i.worseregional i.partyID i.opposeID if ELECID==7  & betternational==0
margins, dydx(worsenational)
margins, dydx(worseregional)

*** Madrid national
logit INCUMBENT i.worsenational i.worseregional i.partyID i.opposeID if ELECID==9  & betternational==0
margins, dydx(worsenational)
margins, dydx(worseregional)

*** Lower Saxony
logit INCUMBENT i.worsenational i.worseregional i.partyID i.opposeID if ELECID==10  & betternational==0
margins, dydx(worsenational)
margins, dydx(worseregional)

*** Bavaria national
logit INCUMBENT i.worsenational i.worseregional i.partyID i.opposeID if ELECID==12  & betternational==0
margins, dydx(worsenational)
margins, dydx(worseregional)

**** Subnational Vote

*** Marseille
logit INCUMBENT i.worsenational i.worseregional i.partyID i.opposeID if ELECID==23  & betterregional==0
margins, dydx(worseregional)
margins, dydx(worsenational)

*** Paris
logit INCUMBENT i.worsenational i.worseregional i.partyID i.opposeID if ELECID==22  & betterregional==0
margins, dydx(worseregional)
margins, dydx(worsenational)

*** Catalonia subnational
logit INCUMBENT i.worsenational i.worseregional i.partyID i.opposeID if ELECID==8  & betterregional==0
margins, dydx(worseregional)
margins, dydx(worsenational)

*** Madrid subnational Missing

*** Lower Saxony subnational
logit INCUMBENT i.worsenational i.worseregional i.partyID i.opposeID if ELECID==11  & betterregional==0
margins, dydx(worseregional)
margins, dydx(worsenational)

*** Bavaria subnational
logit INCUMBENT i.worsenational i.worseregional i.partyID i.opposeID if ELECID==13  & betterregional==0
margins, dydx(worseregional)
margins, dydx(worsenational)


*** National economic perceptions in EU election 

*** IDF EU

tab nationaleconomy if ELECID==17

*** Provence EU

tab nationaleconomy if ELECID==16

*** Catalonia EU

tab nationaleconomy if ELECID==20

*** Madrid EU

tab nationaleconomy if ELECID==21

*** Lower Saxony EU

tab nationaleconomy if ELECID==18

*** Bavaria EU

tab nationaleconomy if ELECID==19

*** European VOTE Table 6

*** IDF EU
logit INCUMBENT i.worsenational i.partyID i.opposeID if ELECID==17 & betternational<2
margins, dydx(worsenational)

*** Provence EU
logit INCUMBENT i.worsenational i.partyID i.opposeID if ELECID==16 & betternational<2
margins, dydx(worsenational)

*** Catalonia EU
logit INCUMBENT i.worsenational i.betternational i.partyID i.opposeID if ELECID==20
margins, dydx(worsenational)
margins, dydx(betternational)

*** Madrid EU
logit INCUMBENT i.worsenational i.betternational i.partyID i.opposeID if ELECID==21
margins, dydx(worsenational)
margins, dydx(betternational)

*** Lower Saxony EU
logit INCUMBENT i.worsenational i.betternational i.partyID i.opposeID if ELECID==18
margins, dydx(worsenational)
margins, dydx(betternational)

*** Bavaria EU
logit INCUMBENT i.worsenational i.betternational i.partyID i.opposeID if ELECID==19
margins, dydx(worsenational)
margins, dydx(betternational)


**** Examining Impact of Cross-level Corruption Perceptions Figure 6

**** National Vote

*** IDF national
gen corrupt=nationalcorrupt
logit INCUMBENT corrupt municipalcorrupt i.partyID i.opposeID if ELECID==5  
margins, at(corrupt=(0 (1) 3)) saving(file1, replace)

drop corrupt
gen corrupt=municipalcorrupt
logit INCUMBENT corrupt nationalcorrupt i.partyID i.opposeID if ELECID==5  
margins, at(corrupt=(0 (1) 3))saving(file2, replace)

combomarginsplot file1 file2, recast(line) recastci(rarea) label("national" "municipal")

drop corrupt

*** Provence national
gen corrupt=nationalcorrupt
logit INCUMBENT corrupt municipalcorrupt i.partyID i.opposeID if ELECID==6 
margins, at(corrupt=(0 (1) 3)) saving(file1, replace)

drop corrupt
gen corrupt=municipalcorrupt
logit INCUMBENT corrupt nationalcorrupt i.partyID i.opposeID if ELECID==6  
margins, at(corrupt=(0 (1) 3))saving(file2, replace)

combomarginsplot file1 file2, recast(line) recastci(rarea) label("national" "municipal")

drop corrupt

*** Catalonia national
gen corrupt=nationalcorrupt
logit INCUMBENT corrupt regionalcorrupt i.partyID i.opposeID if ELECID==7  
margins, at(corrupt=(0 (1) 3)) saving(file1, replace)

drop corrupt
gen corrupt=regionalcorrupt
logit INCUMBENT corrupt nationalcorrupt i.partyID i.opposeID if ELECID==7  
margins, at(corrupt=(0 (1) 3))saving(file2, replace)

combomarginsplot file1 file2, recast(line) recastci(rarea) label("national" "subnational")

drop corrupt

*** Madrid national
gen corrupt=nationalcorrupt
logit INCUMBENT corrupt regionalcorrupt i.partyID i.opposeID if ELECID==9  
margins, at(corrupt=(0 (1) 3)) saving(file1, replace)

drop corrupt
gen corrupt=regionalcorrupt
logit INCUMBENT corrupt nationalcorrupt i.partyID i.opposeID if ELECID==9  
margins, at(corrupt=(0 (1) 3))saving(file2, replace)

combomarginsplot file1 file2, recast(line) recastci(rarea) label("national" "subnational")

drop corrupt

*** Lower Saxony nationa
gen corrupt=nationalcorrupt
logit INCUMBENT corrupt regionalcorrupt i.partyID i.opposeID if ELECID==10  
margins, at(corrupt=(0 (1) 3)) saving(file1, replace)

drop corrupt
gen corrupt=regionalcorrupt
logit INCUMBENT corrupt nationalcorrupt i.partyID i.opposeID if ELECID==10 
margins, at(corrupt=(0 (1) 3))saving(file2, replace)

combomarginsplot file1 file2, recast(line) recastci(rarea) label("national" "subnational")

drop corrupt

*** Bavaria national
gen corrupt=nationalcorrupt
logit INCUMBENT corrupt regionalcorrupt i.partyID i.opposeID if ELECID==12  
margins, at(corrupt=(0 (1) 3)) saving(file1, replace)

drop corrupt
gen corrupt=regionalcorrupt
logit INCUMBENT corrupt nationalcorrupt i.partyID i.opposeID if ELECID==12 
margins, at(corrupt=(0 (1) 3))saving(file2, replace)

combomarginsplot file1 file2, recast(line) recastci(rarea) label("national" "subnational")

drop corrupt

gr combine CIDF.gph CProvence.gph Ccatalonia.gph Cmadrid.gph Cbavaria.gph Csaxony.gph , col(2) ysize(2) xsize(2)


**** Subnational Vote Figure 7

*** Marseille
gen corrupt=nationalcorrupt
logit INCUMBENT corrupt municipalcorrupt i.partyID i.opposeID if ELECID==23  
margins, at(corrupt=(0 (1) 3)) saving(file1, replace)

drop corrupt
gen corrupt=municipalcorrupt
logit INCUMBENT corrupt nationalcorrupt i.partyID i.opposeID if ELECID==23  
margins, at(corrupt=(0 (1) 3))saving(file2, replace)

combomarginsplot file1 file2, recast(line) recastci(rarea) label("national" "municipal")

drop corrupt

*** Paris
gen corrupt=nationalcorrupt
logit INCUMBENT corrupt municipalcorrupt i.partyID i.opposeID if ELECID==22  
margins, at(corrupt=(0 (1) 3)) saving(file1, replace)

drop corrupt
gen corrupt=municipalcorrupt
logit INCUMBENT corrupt nationalcorrupt i.partyID i.opposeID if ELECID==22 
margins, at(corrupt=(0 (1) 3))saving(file2, replace)

combomarginsplot file1 file2, recast(line) recastci(rarea) label("national" "municipal")

drop corrupt

*** Catalonia subnational
gen corrupt=nationalcorrupt
logit INCUMBENT corrupt regionalcorrupt i.partyID i.opposeID if ELECID==8  
margins, at(corrupt=(0 (1) 3)) saving(file1, replace)

drop corrupt
gen corrupt=regionalcorrupt
logit INCUMBENT corrupt nationalcorrupt i.partyID i.opposeID if ELECID==8 
margins, at(corrupt=(0 (1) 3))saving(file2, replace)

combomarginsplot file1 file2, recast(line) recastci(rarea) label("national" "municipal")

drop corrupt

**** Catalonia subnational
gen corrupt=nationalcorrupt
logit INCUMBENT corrupt regionalcorrupt i.partyID i.opposeID if ELECID==8  
margins, at(corrupt=(0 (1) 3)) saving(file1, replace)

drop corrupt
gen corrupt=regionalcorrupt
logit INCUMBENT corrupt nationalcorrupt i.partyID i.opposeID if ELECID==8 
margins, at(corrupt=(0 (1) 3))saving(file2, replace)

combomarginsplot file1 file2, recast(line) recastci(rarea) label("national" "municipal")

drop corrupt

*** Madrid subnational
gen corrupt=nationalcorrupt
logit INCUMBENT corrupt regionalcorrupt i.partyID i.opposeID if ELECID==24  
margins, at(corrupt=(0 (1) 3)) saving(file1, replace)

drop corrupt
gen corrupt=regionalcorrupt
logit INCUMBENT corrupt nationalcorrupt i.partyID i.opposeID if ELECID==24 
margins, at(corrupt=(0 (1) 3))saving(file2, replace)

combomarginsplot file1 file2, recast(line) recastci(rarea) label("national" "municipal")

drop corrupt

**** Lower Saxony subnational
gen corrupt=nationalcorrupt
logit INCUMBENT corrupt regionalcorrupt i.partyID i.opposeID if ELECID==11  
margins, at(corrupt=(0 (1) 3)) saving(file1, replace)

drop corrupt
gen corrupt=regionalcorrupt
logit INCUMBENT corrupt nationalcorrupt i.partyID i.opposeID if ELECID==11
margins, at(corrupt=(0 (1) 3))saving(file2, replace)

combomarginsplot file1 file2, recast(line) recastci(rarea) label("national" "municipal")

drop corrupt

*** Bavaria subnational
gen corrupt=nationalcorrupt
logit INCUMBENT corrupt regionalcorrupt i.partyID i.opposeID if ELECID==13  
margins, at(corrupt=(0 (1) 3)) saving(file1, replace)

drop corrupt
gen corrupt=regionalcorrupt
logit INCUMBENT corrupt nationalcorrupt i.partyID i.opposeID if ELECID==13
margins, at(corrupt=(0 (1) 3))saving(file2, replace)

combomarginsplot file1 file2, recast(line) recastci(rarea) label("national" "municipal")

drop corrupt


gr combine CParis.gph CMarseille.gph CcataloniaS.gph CmadridS.gph CbavariaS.gph CsaxonyS.gph , col(2) ysize(2) xsize(2)


*** Economic Evaluations Figure 1

* Graph - National Economy 

preserve 
drop if inlist(nationaleconomy, 9, .) 
keep if inlist(ELECID, 5, 6, 7, 9, 10, 12) 
proportion nationaleconomy, over(ELECID) 
matrix forgraph = r(table)
matrix list forgraph
clear 
input ELECID nationaleconomy  
5 1
5 2
5 3 
6 1
6 2
6 3
7 1 
7 2
7 3
9 1
9 2
9 3
10 1
10 2
10 3
12 1
12 2 
12 3 
end
gen share = .
replace share = forgraph[1,1] if ELECID == 5 & nationaleconomy == 1
replace share = forgraph[1,2] if ELECID == 6 & nationaleconomy == 1
replace share = forgraph[1,3] if ELECID == 7 & nationaleconomy == 1
replace share = forgraph[1,4] if ELECID == 9 & nationaleconomy == 1
replace share = forgraph[1,5] if ELECID == 10 & nationaleconomy == 1
replace share = forgraph[1,6] if ELECID == 12 & nationaleconomy == 1
replace share = forgraph[1,7] if ELECID == 5 & nationaleconomy == 2
replace share = forgraph[1,8] if ELECID == 6 & nationaleconomy == 2
replace share = forgraph[1,9] if ELECID == 7 & nationaleconomy == 2
replace share = forgraph[1,10] if ELECID == 9 & nationaleconomy == 2
replace share = forgraph[1,11] if ELECID == 10 & nationaleconomy == 2
replace share = forgraph[1,12] if ELECID == 12 & nationaleconomy == 2
replace share = forgraph[1,13] if ELECID == 5 & nationaleconomy == 3
replace share = forgraph[1,14] if ELECID == 6 & nationaleconomy == 3
replace share = forgraph[1,15] if ELECID == 7 & nationaleconomy == 3
replace share = forgraph[1,16] if ELECID == 9 & nationaleconomy == 3
replace share = forgraph[1,17] if ELECID == 10 & nationaleconomy == 3
replace share = forgraph[1,18] if ELECID == 12 & nationaleconomy == 3
replace share = share * 100 // to get percentages
recode ELECID (5=1 "IDF") (6=2 "Provence") (7=3 "Catalonia") (9=4 "Madrid") ///
(12=5 "Bavaria") (10=6 "Lower Saxony"), gen(region)
label variable region Region 
replace region = cond(nationaleconomy == 1, region - 0.3, region + 0)
replace region = cond(nationaleconomy == 3, region + 0.3, region + 0)
replace share = round(share, .1)
tostring share, gen(barlabels) force
replace barlabels = substr(barlabels, 1, 4)
replace barlabels = "5.8" if barlabels == "5.80"
replace barlabels = "2.2" if barlabels == "2.20"
replace barlabels = "1.6" if barlabels == "1.60"
replace barlabels = "33.0" if barlabels == "33"
replace barlabels = barlabels+" "+"%" 
cap ssc install mylabels 
mylabels 0(10)90, local(labels) myscale(@) suffix(" %")
twoway bar share region if nationaleconomy==1, color(gs4) barwidth(0.3) lpattern(l) lcolor(gs0) || ///
       bar share region if nationaleconomy==2, color(gs10) barwidth(0.3) lpattern(l) lcolor(gs0) ||  ///
	   bar share region if nationaleconomy==3, color(gs13) barwidth(0.3) ||  ///
	   scatter share region if nationaleconomy==1, msym(none) mlab(barlabels) mlabpos(12) mlabcolor(black) mlabs(small) || ///
       scatter share region if nationaleconomy==2, msym(none) mlab(barlabels) mlabpos(12) mlabcolor(black) mlabs(small)||  ///
	   scatter share region if nationaleconomy==3, msym(none) mlab(barlabels) mlabpos(12) mlabcolor(black) mlabs(small) ///
	   ylabel(`labels') ///
	   legend(row(1) order(1 "Worse" 2 "About the same" 3 "Better")) lpattern(l) lcolor(gs0) ///   
	   xlabel(2"Provence" 1`" "Ile de" "France" "' 3"Catalonia" 4"Madrid" 5"Bavaria" 6`" "Lower" "Saxony" "') ///
	   ytitle("") scale(0.8)  yscale(range(0(10)90)) saving(nationaleconomy)
restore

*** Graph Subnational Economy

preserve 
drop if inlist(regionaleconomy, 9, .) 
keep if inlist(ELECID, 8, 11, 13, 22, 23) 
proportion regionaleconomy, over(ELECID) 
matrix forgraph = r(table)
matrix list forgraph
clear 
input ELECID regionaleconomy  
8 1
8 2
8 3 
11 1 
11 2
11 3
13 1
13 2
13 3
22 1
22 2
22 3
23 1
23 2 
23 3 
end
gen share = .
replace share = forgraph[1,1] if ELECID == 8 & regionaleconomy == 1
replace share = forgraph[1,2] if ELECID == 11 & regionaleconomy == 1
replace share = forgraph[1,3] if ELECID == 13 & regionaleconomy == 1
replace share = forgraph[1,4] if ELECID == 22 & regionaleconomy == 1
replace share = forgraph[1,5] if ELECID == 23 & regionaleconomy == 1
replace share = forgraph[1,6] if ELECID == 8 & regionaleconomy == 2
replace share = forgraph[1,7] if ELECID == 11 & regionaleconomy == 2
replace share = forgraph[1,8] if ELECID == 13 & regionaleconomy == 2
replace share = forgraph[1,9] if ELECID == 22 & regionaleconomy == 2
replace share = forgraph[1,10] if ELECID == 23 & regionaleconomy == 2
replace share = forgraph[1,11] if ELECID == 8 & regionaleconomy == 3
replace share = forgraph[1,12] if ELECID == 11 & regionaleconomy == 3
replace share = forgraph[1,13] if ELECID == 13 & regionaleconomy == 3
replace share = forgraph[1,14] if ELECID == 22 & regionaleconomy == 3
replace share = forgraph[1,15] if ELECID == 23 & regionaleconomy == 3
replace share = share * 100 // to get percentages
recode ELECID (22=1 "Paris") (23=2 "Marseille") (8=3 "Catalonia")  ///
(13=4 "Bavaria") (11=5 "Lower Saxony"), gen(region)
label variable region Region 
replace region = cond(regionaleconomy == 1, region - 0.3, region + 0)
replace region = cond(regionaleconomy == 3, region + 0.3, region + 0)
replace share = round(share, .1)
tostring share, gen(barlabels) force
replace barlabels = substr(barlabels, 1, 4)
replace barlabels = "5.8" if barlabels == "5.80"
replace barlabels = "2.2" if barlabels == "2.20"
replace barlabels = "1.6" if barlabels == "1.60"
replace barlabels = "33.0" if barlabels == "33"
replace barlabels = barlabels+" "+"%" 
cap ssc install mylabels 
mylabels 0(10)90, local(labels) myscale(@) suffix(" %")
twoway bar share region if regionaleconomy==1, color(gs4) barwidth(0.3) lpattern(l) lcolor(gs0) || ///
       bar share region if regionaleconomy==2, color(gs10) barwidth(0.3) lpattern(l) lcolor(gs0) ||  ///
	   bar share region if regionaleconomy==3, color(gs13) barwidth(0.3) ||  ///
	   scatter share region if regionaleconomy==1, msym(none) mlab(barlabels) mlabpos(12) mlabcolor(black) mlabs(small) || ///
       scatter share region if regionaleconomy==2, msym(none) mlab(barlabels) mlabpos(12) mlabcolor(black) mlabs(small)||  ///
	   scatter share region if regionaleconomy==3, msym(none) mlab(barlabels) mlabpos(12) mlabcolor(black) mlabs(small) ///
	   ylabel(`labels') ///
	   legend(row(1) order(1 "Worse" 2 "About the same" 3 "Better")) lpattern(l) lcolor(gs0) ///   
	   xlabel(2"Marseille" 1"Paris" 3"Catalonia" 4"Bavaria" 5`" "Lower" "Saxony" "') ///
	   ytitle("") scale(0.8)  yscale(range(0(10)90)) fxsize(120) saving(subnationalgraph1, replace) 
restore

gr combine nationaleconomy.gph subnationalgraph1.gph, ysize(2) xsize(3) col(1)

**** Attributions of Responsibility Figure 2

**** National Economy
preserve
keep if inlist(ELECID, 5, 6, 7, 9, 10, 12) 
proportion nationalresponsibility, over(ELECID) 
matrix forgraph = r(table)
matrix list forgraph
clear 
input ELECID nationalresponsibility
5 1
5 2
5 3 
6 1
6 2
6 3
7 1 
7 2
7 3
9 1
9 2
9 3
10 1
10 2
10 3
12 1
12 2 
12 3 
end
gen share = .
replace share = forgraph[1,1] if ELECID == 5 & nationalresponsibility == 1
replace share = forgraph[1,2] if ELECID == 6 & nationalresponsibility == 1
replace share = forgraph[1,3] if ELECID == 7 & nationalresponsibility == 1
replace share = forgraph[1,4] if ELECID == 9 & nationalresponsibility == 1
replace share = forgraph[1,5] if ELECID == 10 & nationalresponsibility == 1
replace share = forgraph[1,6] if ELECID == 12 & nationalresponsibility == 1
replace share = forgraph[1,7] if ELECID == 5 & nationalresponsibility == 2
replace share = forgraph[1,8] if ELECID == 6 & nationalresponsibility == 2
replace share = forgraph[1,9] if ELECID == 7 & nationalresponsibility == 2
replace share = forgraph[1,10] if ELECID == 9 & nationalresponsibility == 2
replace share = forgraph[1,11] if ELECID == 10 & nationalresponsibility == 2
replace share = forgraph[1,12] if ELECID == 12 & nationalresponsibility == 2
replace share = forgraph[1,13] if ELECID == 5 & nationalresponsibility == 3
replace share = forgraph[1,14] if ELECID == 6 & nationalresponsibility == 3
replace share = forgraph[1,15] if ELECID == 7 & nationalresponsibility == 3
replace share = forgraph[1,16] if ELECID == 9 & nationalresponsibility == 3
replace share = forgraph[1,17] if ELECID == 10 & nationalresponsibility == 3
replace share = forgraph[1,18] if ELECID == 12 & nationalresponsibility == 3
replace share = share * 100 // to get percentages
recode ELECID (5=1 "IDF") (6=2 "Provence") (7=3 "Catalonia") (9=4 "Madrid") ///
(12=5 "Bavaria") (10=6 "Lower Saxony"), gen(region)
label variable region Region 
replace region = cond(nationalresponsibility == 1, region - 0.3, region + 0)
replace region = cond(nationalresponsibility == 3, region + 0.3, region + 0)
replace share = round(share, .1)
tostring share, gen(barlabels) force
replace barlabels = substr(barlabels, 1, 4)
replace barlabels = "5.8" if barlabels == "5.80"
replace barlabels = "2.2" if barlabels == "2.20"
replace barlabels = "1.6" if barlabels == "1.60"
replace barlabels = "33.0" if barlabels == "33"
replace barlabels = barlabels // +" "+"%" 
cap ssc install mylabels 
mylabels 0(10)90, local(labels) myscale(@) suffix(" %")
twoway bar share region if nationalresponsibility==1, color(gs4) barwidth(0.3) lpattern(l) lcolor(gs0) || ///
       bar share region if nationalresponsibility==2, color(gs10) barwidth(0.3) lpattern(l) lcolor(gs0) ||  ///
	   bar share region if nationalresponsibility==3, color(gs13) barwidth(0.3) ||  ///
	   scatter share region if nationalresponsibility==1, msym(none) mlab(barlabels) mlabpos(12) mlabcolor(black) mlabs(vsmall) || ///
       scatter share region if nationalresponsibility==2, msym(none) mlab(barlabels) mlabpos(12) mlabcolor(black) mlabs(vsmall)||  ///
	   scatter share region if nationalresponsibility==3, msym(none) mlab(barlabels) mlabpos(12) mlabcolor(black) mlabs(vsmall) ///
	   ylabel(`labels') ///
	   legend(row(3) order(1 "worse" 2 "not much difference" 3 "better"))  lpattern(l) lcolor(gs0) ///   
	   xlabel(2"Provence" 1`" "Ile de" "France" "' 3"Catalonia" 4"Madrid" 5"Bavaria" 6`" "Lower" "Saxony" "') ///
	   ytitle("") scale(0.8) xtitle("Region", margin(medium)) yscale(range(0(10)90)) name(right_graph, replace) fxsize(150) ///
	   title("The National Economy") 
restore

**** Subnational Economy
preserve
keep if inlist(ELECID, 8, 11, 13)  
proportion regionalresponsibility, over(ELECID) 
matrix forgraph = r(table)
matrix list forgraph
clear 
input ELECID regonalresponsibility 
8 1
8 2
8 3 
11 1
11 2
11 3
13 1 
13 2
13 3
end
gen share = .
replace share = forgraph[1,1] if ELECID == 8 & regonalresponsibility == 1
replace share = forgraph[1,2] if ELECID == 11 & regonalresponsibility == 1
replace share = forgraph[1,3] if ELECID == 13 & regonalresponsibility == 1
replace share = forgraph[1,4] if ELECID == 8 & regonalresponsibility == 2
replace share = forgraph[1,5] if ELECID == 11 & regonalresponsibility == 2
replace share = forgraph[1,6] if ELECID == 13 & regonalresponsibility == 2
replace share = forgraph[1,7] if ELECID == 8 & regonalresponsibility == 3
replace share = forgraph[1,8] if ELECID == 11 & regonalresponsibility == 3
replace share = forgraph[1,9] if ELECID == 13 & regonalresponsibility == 3
replace share = share * 100 // to get percentages
recode ELECID (8=1 "Catalonia") (11=3 "Lower Saxony") (13=2 "Bavaria"), gen(region)
label variable region Region 
replace region = cond(regonalresponsibility == 1, region - 0.3, region + 0)
replace region = cond(regonalresponsibility == 3, region + 0.3, region + 0)
replace share = round(share, .1)
cap drop barlabels
tostring share, gen(barlabels) force
replace barlabels = substr(barlabels, 1, 4)
/*replace barlabels = "5.8" if barlabels == "5.80"
replace barlabels = "2.2" if barlabels == "2.20"
replace barlabels = "1.6" if barlabels == "1.60"
replace barlabels = "33.0" if barlabels == "33"*/
replace barlabels = barlabels // +" "+"%" 
cap ssc install mylabels 
mylabels 0(10)90, local(labels) myscale(@) suffix(" %")
twoway bar share region if regonalresponsibility==1, color(gs4) barwidth(0.3) lpattern(l) lcolor(gs0) || ///
       bar share region if regonalresponsibility==2, color(gs10) barwidth(0.3) lpattern(l) lcolor(gs0) ||  ///
	   bar share region if regonalresponsibility==3, color(gs13) barwidth(0.3) ||  ///
	   scatter share region if regonalresponsibility==1, msym(none) mlab(barlabels) mlabpos(12) mlabcolor(black) mlabs(vsmall) || ///
       scatter share region if regonalresponsibility==2, msym(none) mlab(barlabels) mlabpos(12) mlabcolor(black) mlabs(vsmall)||  ///
	   scatter share region if regonalresponsibility==3, msym(none) mlab(barlabels) mlabpos(12) mlabcolor(black) mlabs(vsmall) ///
	   ylabel(`labels') ///
	   legend(row(3) order(1 "worse" 2 "not much difference" 3 "same"))  lpattern(l) lcolor(gs0) ///   
	   xlabel(1"Catalonia"  2"Bavaria" 3`" "Lower" "Saxony" "') ///
	   ytitle("") scale(0.8) xtitle("Region", margin(medium)) yscale(range(0(10)90)) name(left_graph, replace) fxsize(85) ///
	   title("The Subnational Economy") 
restore

graph combine right_graph left_graph, col(2)

**** Corruption Figure 3
replace regionalcorrupt=municipalcorrupt if ELECID==22
replace regionalcorrupt=municipalcorrupt if ELECID==23

preserve 
keep if inlist(ELECID, 5, 6, 7, 9, 10, 12) 
proportion Q50B, over(ELECID)
matrix forgraph_national = r(table)
matrix list forgraph_national 
restore 

preserve 

keep if inlist(ELECID, 8, 11, 13, 22, 23, 24) 
rename ELECID temp1
recode temp1 (22=5) (23=6) (8=7) (24=9) (11=10) (13=12), gen(ELECID) 
proportion Q50A, over(ELECID) 
matrix forgraph_regional = r(table)
matrix list forgraph_regional 
restore 


preserve 
clear 
input ELECID national  
5 1
5 0 
6 1
6 0
7 1 
7 0
9 1
9 0
10 1
10 0
12 1
12 0 
end
gen share = .
replace share = forgraph_regional[1,19] if ELECID == 5 & national == 0 
replace share = forgraph_regional[1,20] if ELECID == 6 & national == 0
replace share = forgraph_regional[1,21] if ELECID == 7 & national == 0
replace share = forgraph_regional[1,22] if ELECID == 9 & national == 0
replace share = forgraph_regional[1,23] if ELECID == 10 & national == 0
replace share = forgraph_regional[1,24] if ELECID == 12 & national == 0
replace share = forgraph_national[1,19] if ELECID == 5 & national == 1
replace share = forgraph_national[1,20] if ELECID == 6 & national == 1
replace share = forgraph_national[1,21] if ELECID == 7 & national == 1
replace share = forgraph_national[1,22] if ELECID == 9 & national == 1
replace share = forgraph_national[1,23] if ELECID == 10 & national == 1
replace share = forgraph_national[1,24] if ELECID == 12 & national == 1
replace share = share * 100 // to get percentages
recode ELECID (5=1 "IDF") (6=2 "Provence") (7=3 "Catalonia") (9=4 "Madrid") ///
(12=5 "Bavaria") (10=6 "Lower Saxony"), gen(region)
label variable region Region 
replace region = cond(national == 0, region - 0.15, region + 0)
replace region = cond(national == 1, region + 0.15, region + 0)
replace share = round(share, .1)
tostring share, gen(barlabels) force
replace barlabels = substr(barlabels, 1, 4)
*replace barlabels = "rounded value to one decimal" if barlabels == "original form" // if you want to have the same number of decimal places
*replace barlabels = barlabels // +" "+"%" 
cap ssc install mylabels 
mylabels 0(10)60, local(labels) myscale(@) suffix(" %")
twoway  bar share region if national==0, color(gs10) barwidth(0.3) lpattern(l) lcolor(gs0) ||  ///
		bar share region if national==1, color(gs4) barwidth(0.3) lpattern(l) lcolor(gs0) || ///
	    scatter share region if national==0, msym(none) mlab(barlabels) mlabpos(12) mlabcolor(black) mlabs(vsmall)  || ///
	   scatter share region if national==1, msym(none) mlab(barlabels) mlabpos(12) mlabcolor(black) mlabs(vsmall) ///
	   ylabel(`labels') ///
	   legend(row(1) order(1 "Subnational" 2 "National")) lpattern(l) lcolor(gs0) ///   
	   xlabel(2"Provence" 1`" "Ile de" "France" "' 3"Catalonia" 4"Madrid" 5"Bavaria" 6`" "Lower" "Saxony" "') ///
	   ytitle("") scale(0.8) xtitle(("Region"), margin(medium)) yscale(range(0(10)60)) fxsize(150) ///
	   title("") 
restore
